/*
 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef __TDE_FILTERPARA_H__
#define __TDE_FILTERPARA_H__

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

#define TDE_PARA_TABLE_SIZE 32
#define TDE_PARA_TABLE_ORG_SIZE 40
#define TDE_PARA_TABLE_NUM 12

#define TDE_PARA_VTABLE_ORG_SIZE (17 * 2)

#define TDE_PARA_HTABLE_ORG_SIZE (17 * 3)
#define TDE_PARA_HTABLE_SIZE     (64 * 4)
#define TDE_PARA_HTABLE_NUM      7

#define TDE_PARA_VTABLE_SIZE (64 * 4)
#define TDE_PARA_VTABLE_NUM 7

/* vertical filter coefficient */
hi_u32 g_org_vf_coef[TDE_PARA_VTABLE_ORG_SIZE * TDE_PARA_HTABLE_NUM] = {
    /* ratio is greater than 1.0 */
    0x3f0000,
    0x0,
    0x3f0000,
    0x1,
    0x3f03fe,
    0x3,
    0x3f03fd,
    0x3ff0005,
    0x3f03fc,
    0x3ff0006,
    0x3d03fc,
    0x3ff0008,
    0x3c03fb,
    0x3ff000a,
    0x3b03fb,
    0x3fe000c,
    0x3803fb,
    0x3fe000f,
    0x3603fb,
    0x3fe0011,
    0x3403fa,
    0x3fe0014,
    0x3203fb,
    0x3fd0016,
    0x2f03fb,
    0x3fd0019,
    0x2c03fb,
    0x3fd001c,
    0x2a03fb,
    0x3fc001f,
    0x2703fb,
    0x3fc0022,
    0x2403fc,
    0x3fc0024,

    /* ratio is equal to 1.0 */
    0x3f0000,
    0x0,
    0x3f0000,
    0x1,
    0x3f03fe,
    0x3,
    0x3f03fd,
    0x3ff0005,
    0x3f03fc,
    0x3ff0006,
    0x3d03fc,
    0x3ff0008,
    0x3c03fb,
    0x3ff000a,
    0x3b03fb,
    0x3fe000c,
    0x3803fb,
    0x3fe000f,
    0x3603fb,
    0x3fe0011,
    0x3403fa,
    0x3fe0014,
    0x3203fb,
    0x3fd0016,
    0x2f03fb,
    0x3fd0019,
    0x2c03fb,
    0x3fd001c,
    0x2a03fb,
    0x3fc001f,
    0x2703fb,
    0x3fc0022,
    0x2403fc,
    0x3fc0024,

    /* ratio is greater than 0.75 */
    0x3f0000,
    0x0,
    0x3f0000,
    0x1,
    0x3f03fe,
    0x3,
    0x3f03fd,
    0x3ff0005,
    0x3f03fc,
    0x3ff0006,
    0x3d03fc,
    0x3ff0008,
    0x3c03fb,
    0x3ff000a,
    0x3b03fb,
    0x3fe000c,
    0x3803fb,
    0x3fe000f,
    0x3603fb,
    0x3fe0011,
    0x3403fa,
    0x3fe0014,
    0x3203fb,
    0x3fd0016,
    0x2f03fb,
    0x3fd0019,
    0x2c03fb,
    0x3fd001c,
    0x2a03fb,
    0x3fc001f,
    0x2703fb,
    0x3fc0022,
    0x2403fc,
    0x3fc0024,

    /* ratio is not less than 0.5 */
    0x31000a,
    0x3fb000a,
    0x330008,
    0x3fa000b,
    0x320007,
    0x3fa000d,
    0x330005,
    0x3f9000f,
    0x330004,
    0x3f90010,
    0x320003,
    0x3f90012,
    0x320001,
    0x3f90014,
    0x320000,
    0x3f80016,
    0x3103ff,
    0x3f80018,
    0x3003fe,
    0x3f8001a,
    0x2f03fd,
    0x3f8001c,
    0x2e03fc,
    0x3f8001e,
    0x2c03fc,
    0x3f80020,
    0x2c03fb,
    0x3f80021,
    0x2a03fa,
    0x3f90023,
    0x2803fa,
    0x3f90025,
    0x2703f9,
    0x3f90027,

    /* ratio is greater than 0.33 */
    0x170011,
    0x70011,
    0x170011,
    0x70011,
    0x160010,
    0x80012,
    0x160010,
    0x80012,
    0x160010,
    0x80012,
    0x17000f,
    0x80012,
    0x16000f,
    0x90012,
    0x15000f,
    0x90013,
    0x16000e,
    0x90013,
    0x16000e,
    0x90013,
    0x15000e,
    0xa0013,
    0x16000d,
    0xa0013,
    0x15000d,
    0xa0014,
    0x14000d,
    0xb0014,
    0x15000c,
    0xb0014,
    0x15000c,
    0xb0014,
    0x15000c,
    0xb0014,

    /* ratio is greater than 0.25 */
    0x130011,
    0xb0011,
    0x130011,
    0xb0011,
    0x130010,
    0xc0011,
    0x130010,
    0xc0011,
    0x130010,
    0xc0011,
    0x130010,
    0xc0011,
    0x130010,
    0xc0011,
    0x14000f,
    0xc0011,
    0x13000f,
    0xd0011,
    0x12000f,
    0xd0012,
    0x12000f,
    0xd0012,
    0x12000f,
    0xd0012,
    0x12000f,
    0xd0012,
    0x13000e,
    0xd0012,
    0x12000e,
    0xe0012,
    0x12000e,
    0xe0012,
    0x12000e,
    0xe0012,

    /* ratio is less than 0.25 */
    0x110011,
    0xd0011,
    0x120010,
    0xd0011,
    0x120010,
    0xd0011,
    0x120010,
    0xd0011,
    0x120010,
    0xd0011,
    0x120010,
    0xd0011,
    0x120010,
    0xd0011,
    0x110010,
    0xe0011,
    0x110010,
    0xe0011,
    0x12000f,
    0xe0011,
    0x12000f,
    0xe0011,
    0x12000f,
    0xe0011,
    0x12000f,
    0xe0011,
    0x12000f,
    0xe0011,
    0x12000f,
    0xe0011,
    0x12000f,
    0xe0011,
    0x11000f,
    0xf0011,
};

#ifndef HI_BUILD_IN_BOOT
/* anti-flash filter coefficient */
hi_u32 g_deflicker_vf_coef[TDE_PARA_VTABLE_ORG_SIZE * TDE_PARA_HTABLE_NUM] = {
    /* ratio is greater than 1 */
    0x1f0011,
    0x3ff0011,
    0x1f0011,
    0x3ff0011,
    0x1e0010,
    0x12,
    0x1e0010,
    0x12,
    0x1e000f,
    0x13,
    0x1e000f,
    0x13,
    0x1e000d,
    0x10014,
    0x1e000d,
    0x10014,
    0x1d000b,
    0x20016,
    0x1d000b,
    0x20016,
    0x1d000a,
    0x20017,
    0x1d000a,
    0x20017,
    0x1d0008,
    0x30018,
    0x1d0008,
    0x30018,
    0x1c0007,
    0x40019,
    0x1c0007,
    0x40019,
    0x1a0006,
    0x6001a,
    /* ratio is equal to  1 */
    0x200010,
    0x10,
    0x1f000f,
    0x10011,
    0x1f000e,
    0x10012,
    0x1f000c,
    0x20013,
    0x1f000b,
    0x20014,
    0x1f000a,
    0x20015,
    0x1e0009,
    0x30016,
    0x1e0009,
    0x30016,
    0x1e0008,
    0x30017,
    0x1d0008,
    0x40017,
    0x1d0007,
    0x40018,
    0x1c0007,
    0x40019,
    0x1c0007,
    0x40019,
    0x1c0006,
    0x4001a,
    0x1b0006,
    0x5001a,
    0x1b0005,
    0x5001b,
    0x1b0005,
    0x5001b,
    /* ratio is less than 1, and not less than 0.75 */
    0x1f0011,
    0x3ff0011,
    0x1f0011,
    0x3ff0011,
    0x1e0010,
    0x12,
    0x1e0010,
    0x12,
    0x1e000e,
    0x10013,
    0x1e000e,
    0x10013,
    0x1e000d,
    0x10014,
    0x1e000d,
    0x10014,
    0x1e000b,
    0x20015,
    0x1e000b,
    0x20015,
    0x1c000a,
    0x30017,
    0x1c000a,
    0x30017,
    0x1b0009,
    0x40018,
    0x1b0009,
    0x40018,
    0x1b0007,
    0x50019,
    0x1b0007,
    0x50019,
    0x1a0006,
    0x6001a,
    /* ratio is less than 0.75, and not less than 0.5 */
    0x1e0011,
    0x11,
    0x1e0011,
    0x11,
    0x1d0010,
    0x10012,
    0x1d0010,
    0x10012,
    0x1d000f,
    0x10013,
    0x1d000f,
    0x10013,
    0x1d000d,
    0x20014,
    0x1d000d,
    0x20014,
    0x1c000c,
    0x30015,
    0x1c000c,
    0x30015,
    0x1c000a,
    0x40016,
    0x1c000a,
    0x40016,
    0x1b0009,
    0x50017,
    0x1b0009,
    0x50017,
    0x1a0008,
    0x60018,
    0x1a0008,
    0x60018,
    0x190007,
    0x70019,
    /* ratio is less than 0.5, and not less than 0.33 */
    0x1d0011,
    0x10011,
    0x1d0011,
    0x10011,
    0x1d0010,
    0x10012,
    0x1d0010,
    0x10012,
    0x1c000f,
    0x20013,
    0x1c000f,
    0x20013,
    0x1c000d,
    0x30014,
    0x1c000d,
    0x30014,
    0x1b000c,
    0x40015,
    0x1b000c,
    0x40015,
    0x1b000b,
    0x40016,
    0x1b000b,
    0x40016,
    0x1a000a,
    0x50017,
    0x1a000a,
    0x50017,
    0x1a0008,
    0x60018,
    0x1a0008,
    0x60018,
    0x190007,
    0x70019,

    /* ratio is less than 0.33, and not less than 0.25 */
    0x1c0011,
    0x20011,
    0x1c0011,
    0x20011,
    0x1c0010,
    0x20012,
    0x1c0010,
    0x20012,
    0x1b000f,
    0x30013,
    0x1b000f,
    0x30013,
    0x1b000e,
    0x30014,
    0x1b000e,
    0x30014,
    0x1a000d,
    0x40015,
    0x1a000d,
    0x40015,
    0x1a000c,
    0x50015,
    0x1a000c,
    0x50015,
    0x1a000a,
    0x60016,
    0x1a000a,
    0x60016,
    0x190009,
    0x70017,
    0x190009,
    0x70017,
    0x180008,
    0x80018,
    /* ratio is less than 0.25 */
    0x1b0011,
    0x30011,
    0x1b0011,
    0x30011,
    0x1b0010,
    0x30012,
    0x1b0010,
    0x30012,
    0x1a000f,
    0x40013,
    0x1a000f,
    0x40013,
    0x1a000e,
    0x50013,
    0x1a000e,
    0x50013,
    0x1a000d,
    0x50014,
    0x1a000d,
    0x50014,
    0x19000c,
    0x60015,
    0x19000c,
    0x60015,
    0x18000b,
    0x70016,
    0x18000b,
    0x70016,
    0x17000a,
    0x80017,
    0x17000a,
    0x80017,
    0x170009,
    0x90017,
};
#endif

/* horizontal DE_PARA_HTABLE_SIZE  unit:byte */
hi_u32 g_tde_6x32_coef[TDE_PARA_HTABLE_ORG_SIZE * TDE_PARA_HTABLE_NUM] = {
    /* ratio is greater than 1 */
    0x5ff800,
    0x3fe0143a,
    0x0,
    0x4ffc00,
    0x3fe01839,
    0x0,
    0x2ffc00,
    0x3fe02039,
    0x0,
    0x1ffc00,
    0x3fe02838,
    0x0,
    0xffc00,
    0x3fd02c39,
    0x0,
    0x3ff00000,
    0x3fd03437,
    0x0,
    0x3fe00000,
    0x3fd03c36,
    0x0,
    0x3fd00000,
    0x3fc04436,
    0x0,
    0x3fd00000,
    0x3fc04c33,
    0x1,
    0x3fc00000,
    0x3fc05432,
    0x1,
    0x3fc00000,
    0x3fc0602f,
    0x1,
    0x3fb00000,
    0x3fb0682f,
    0x1,
    0x3fb00000,
    0x3fb0702d,
    0x1,
    0x3fb00000,
    0x3fb0782b,
    0x1,
    0x3fb00400,
    0x3fb08028,
    0x1,
    0x3fb00400,
    0x3fb08c25,
    0x1,
    0x3fb00400,
    0x3fb09423,
    0x1,

    /* ratio is equal to 1 */
    0x0,
    0x3f,
    0x0,
    0x4ffc00,
    0x3fe01839,
    0x0,
    0x2ffc00,
    0x3fe02039,
    0x0,
    0x1ffc00,
    0x3fe02838,
    0x0,
    0xffc00,
    0x3fd02c39,
    0x0,
    0x3ff00000,
    0x3fd03437,
    0x0,
    0x3fe00000,
    0x3fd03c36,
    0x0,
    0x3fd00000,
    0x3fc04436,
    0x0,
    0x3fd00000,
    0x3fc04c33,
    0x1,
    0x3fc00000,
    0x3fc05432,
    0x1,
    0x3fc00000,
    0x3fc0602f,
    0x1,
    0x3fb00000,
    0x3fb0682f,
    0x1,
    0x3fb00000,
    0x3fb0702d,
    0x1,
    0x3fb00000,
    0x3fb0782b,
    0x1,
    0x3fb00400,
    0x3fb08028,
    0x1,
    0x3fb00400,
    0x3fb08c25,
    0x1,
    0x3fb00400,
    0x3fb09423,
    0x1,

    /* ratio is less than 1, and not less than 0.75 */
    0xffe000,
    0x3f803c2f,
    0x3,
    0xdfe000,
    0x3f704031,
    0x3,
    0xcfe000,
    0x3f704831,
    0x2,
    0xafe000,
    0x3f704c32,
    0x2,
    0x9fe000,
    0x3f705431,
    0x2,
    0x7fe400,
    0x3f705831,
    0x2,
    0x6fe400,
    0x3f706031,
    0x1,
    0x5fe400,
    0x3f706830,
    0x1,
    0x4fe800,
    0x3f806c2e,
    0x1,
    0x2fe800,
    0x3f80742f,
    0x0,
    0x1fec00,
    0x3f80782e,
    0x0,
    0xfec00,
    0x3f90802d,
    0x3ff,
    0x3fffec00,
    0x3f90882c,
    0x3ff,
    0x3feff000,
    0x3fa08c2a,
    0x3ff,
    0x3fdff000,
    0x3fa0902b,
    0x3fe,
    0x3fcff400,
    0x3fb09828,
    0x3fe,
    0x3fcff400,
    0x3fc09c27,
    0x3fd,

    /* ratio is less than 0.75, and not less than 0.5 */
    0x1200400,
    0x10481e,
    0x3fc,
    0x1200400,
    0x204c1c,
    0x3fc,
    0x1100400,
    0x204c1d,
    0x3fc,
    0x1100000,
    0x20501d,
    0x3fc,
    0x1000000,
    0x30501d,
    0x3fc,
    0xf00000,
    0x30541d,
    0x3fc,
    0xfffc00,
    0x40581c,
    0x3fc,
    0xeffc00,
    0x40581d,
    0x3fc,
    0xeffc00,
    0x505c1b,
    0x3fc,
    0xdff800,
    0x505c1d,
    0x3fc,
    0xcff800,
    0x60601c,
    0x3fc,
    0xcff800,
    0x60601c,
    0x3fc,
    0xbff800,
    0x70601c,
    0x3fc,
    0xbff400,
    0x70641b,
    0x3fd,
    0xaff400,
    0x80641b,
    0x3fd,
    0xaff400,
    0x80681a,
    0x3fd,
    0x9ff400,
    0x90681a,
    0x3fd,

    /* ratio is less than 0.5, and not less than 0.33 */
    0xf01c00,
    0x703c13,
    0x1,
    0xf01c00,
    0x803c12,
    0x1,
    0xe01c00,
    0x803c12,
    0x2,
    0xe01c00,
    0x803c12,
    0x2,
    0xe01c00,
    0x803c12,
    0x2,
    0xe01800,
    0x904011,
    0x2,
    0xd01800,
    0x904012,
    0x2,
    0xd01800,
    0x904012,
    0x2,
    0xd01800,
    0x904011,
    0x3,
    0xd01400,
    0x904012,
    0x3,
    0xc01400,
    0xa04012,
    0x3,
    0xc01400,
    0xa04012,
    0x3,
    0xc01400,
    0xa04411,
    0x3,
    0xc01400,
    0xa04411,
    0x3,
    0xc01000,
    0xb04410,
    0x4,
    0xb01000,
    0xb04411,
    0x4,
    0xb01000,
    0xb04411,
    0x4,

    /* ratio is less than 0.33,and not less than 0.25 */
    0xf01c00,
    0x703c13,
    0x1,
    0xf01c00,
    0x803c12,
    0x1,
    0xe01c00,
    0x803c12,
    0x2,
    0xe01c00,
    0x803c12,
    0x2,
    0xe01c00,
    0x803c12,
    0x2,
    0xe01800,
    0x904011,
    0x2,
    0xd01800,
    0x904012,
    0x2,
    0xd01800,
    0x904012,
    0x2,
    0xd01800,
    0x904011,
    0x3,
    0xd01400,
    0x904012,
    0x3,
    0xc01400,
    0xa04012,
    0x3,
    0xc01400,
    0xa04012,
    0x3,
    0xc01400,
    0xa04411,
    0x3,
    0xc01400,
    0xa04411,
    0x3,
    0xc01000,
    0xb04410,
    0x4,
    0xb01000,
    0xb04411,
    0x4,
    0xb01000,
    0xb04411,
    0x4,

    /* ratio is less than 0.25 */
    0xe02000,
    0x803812,
    0x2,
    0xe02000,
    0x803811,
    0x3,
    0xe02000,
    0x803811,
    0x3,
    0xe01c00,
    0x903c10,
    0x3,
    0xd01c00,
    0x903c11,
    0x3,
    0xd01c00,
    0x903c11,
    0x3,
    0xd01c00,
    0x903c11,
    0x3,
    0xd01c00,
    0x903c11,
    0x3,
    0xd01800,
    0xa03c10,
    0x4,
    0xd01800,
    0xa03c10,
    0x4,
    0xc01800,
    0xa03c11,
    0x4,
    0xc01800,
    0xa04010,
    0x4,
    0xc01800,
    0xa04010,
    0x4,
    0xc01400,
    0xb04010,
    0x4,
    0xc01400,
    0xb0400f,
    0x5,
    0xb01400,
    0xb04010,
    0x5,
    0xb01400,
    0xb04010,
    0x5,
};
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* __TDE_FILTERPARA_H__ */
